var t = require;
var e = module;
var o = exports;
var i, n = this && this.__extends || (i = function(t, e) {
    return (i = Object.setPrototypeOf || {
        __proto__: []
    }
    instanceof Array &&
    function(t, e) {
        t.__proto__ = e
    } ||
    function(t, e) {
        for (var o in e) Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o])
    })(t, e)
},
function(t, e) {
    function o() {
        this.constructor = t
    }
    i(t, e),
    t.prototype = null === e ? Object.create(e) : (o.prototype = e.prototype, new o)
}),
a = this && this.__decorate ||
function(t, e, o, i) {
    var n, a = arguments.length,
    r = a < 3 ? e: null === i ? i = Object.getOwnPropertyDescriptor(e, o) : i;
    if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(t, e, o, i);
    else for (var s = t.length - 1; s >= 0; s--)(n = t[s]) && (r = (a < 3 ? n(r) : a > 3 ? n(e, o, r) : n(e, o)) || r);
    return a > 3 && r && Object.defineProperty(e, o, r),
    r
};
Object.defineProperty(o, "__esModule", {
    value: !0
});
var r = t("CarConstant"),
s = t("AssemblyItem"),
l = cc._decorator,
c = l.ccclass,
d = l.property,
h = function(t) {
    function e() {
        var e = null !== t && t.apply(this, arguments) || this;
        return e.node_content = null,
        e.pfb_assembly = null,
        e.label_state = null,
        e.sp_cross = null,
        e.equipBodyData = null,
        e.equipWheelData = [],
        e.equipWeaponData = [],
        e.equipToolsData = [],
        e.equipCarBody = null,
        e.equipCarWheel = [null, null],
        e.equipCarWeapon = [null, null],
        e.equipCarTools = [null, null],
        e.equipWheelRadius = 0,
        e
    }
    return n(e, t),
    e.prototype.start = function() {
        this.sp_cross.node.active = !1
    },
    e.prototype.init = function(t, e, o, i, n) {
        this._isSelf = n,
        this.createCarBody(t),
        this.createCarWheel(e),
        this.createCarWeapon(o),
        this.createCarTools(i),
        n || (this.node_content.scaleX = -this.node_content.scaleX)
    },
    Object.defineProperty(e.prototype, "State", {
        get: function() {
            return this._state
        },
        enumerable: !1,
        configurable: !0
    }),
    Object.defineProperty(e.prototype, "IsSelf", {
        get: function() {
            return this._isSelf
        },
        enumerable: !1,
        configurable: !0
    }),
    Object.defineProperty(e.prototype, "EquipCarBody", {
        get: function() {
            return this.equipBodyData
        },
        enumerable: !1,
        configurable: !0
    }),
    Object.defineProperty(e.prototype, "EquipCarWheel", {
        get: function() {
            return this.equipWheelData
        },
        enumerable: !1,
        configurable: !0
    }),
    Object.defineProperty(e.prototype, "EquipCarWeapon", {
        get: function() {
            return this.equipWeaponData
        },
        enumerable: !1,
        configurable: !0
    }),
    Object.defineProperty(e.prototype, "EquipCarTools", {
        get: function() {
            return this.equipToolsData
        },
        enumerable: !1,
        configurable: !0
    }),
    e.prototype.createCarBody = function(t) {
        var e = t;
        if (this.equipBodyData = e, !this.equipCarBody) {
            var o = cc.instantiate(this.pfb_assembly);
            this.node_content.addChild(o),
            this.equipCarBody = o.getComponent(s.AssemblyItem)
        }
        this.equipCarBody.updateItem(null, this._isSelf, 0, e, !1, s.Assembly_Type.SuperCar, !0, !0)
    },
    e.prototype.createCarWheel = function(t) {
        for (var e = 0; e < t.length; e++) {
            var o = t[e];
            if (o) {
                this.equipWheelData[e] = o,
                this.equipWheelRadius = this.equipWheelRadius < o.radius && o.radius;
                var i = cc.instantiate(this.pfb_assembly);
                this.node_content.addChild(i, 20),
                i.position = r.GetCarBodyData(this.equipBodyData.id).wheelPos[e],
                this.equipCarWheel[e] = i.getComponent(s.AssemblyItem),
                this.equipCarWheel[e].updateItem(null, this._isSelf, 0, o, !1, s.Assembly_Type.SuperCar)
            } else this.equipWheelData[e] = null,
            this.equipCarWheel[e] = null
        }
    },
    e.prototype.createCarWeapon = function(t) {
        for (var e = 0; e < t.length; e++) {
            var o = t[e];
            if (o) {
                this.equipWeaponData[e] = o;
                var i = cc.instantiate(this.pfb_assembly);
                this.node_content.addChild(i, 30),
                i.position = r.GetCarBodyData(this.equipBodyData.id).weaponPos[e],
                this.equipCarWeapon[e] = i.getComponent(s.AssemblyItem),
                this.equipCarWeapon[e].updateItem(null, this._isSelf, 0, o, !1, s.Assembly_Type.SuperCar)
            } else this.equipWeaponData[e] = null,
            this.equipCarWeapon[e] = null
        }
    },
    e.prototype.createCarTools = function(t) {
        for (var e = 0; e < t.length; e++) {
            var o = t[e];
            if (o) {
                this.equipToolsData[e] = o;
                var i = cc.instantiate(this.pfb_assembly);
                this.node_content.addChild(i, 40),
                i.position = r.GetCarBodyData(this.equipBodyData.id).toolsPos[e],
                this.equipCarTools[e] = i.getComponent(s.AssemblyItem),
                this.equipCarTools[e].updateItem(null, this._isSelf, 0, o, !1, s.Assembly_Type.SuperCar)
            } else this.equipToolsData[e] = null,
            this.equipCarTools[e] = null
        }
    },
    e.prototype.refreshState = function(t) {
        switch (this._state = t, t) {
            case 1:
                this.label_state.string = "战斗中",
            this.node.scale = 1.2;
            break;
            case 2:
                this.sp_cross.node.active = !0,
            this.sp_cross.setAnimation(0, "animation", !1),
            this.label_state.string = "战败",
            this.node.scale = 1;
            break;
            default: this.label_state.string = "战斗中",
            this.node.scale = 1;
        }
    },
    e.prototype.endState = function(t) {
        switch (this.node.scale = 1.2, this._state = t, t) {
            case 1:
                this.label_state.string = "存活";
            break;
            case 2:
                this.sp_cross.node.active = !0,
            this.sp_cross.setAnimation(0, "animation", !1),
            this.label_state.string = "战败";
            break;
            default: this.label_state.string = "存活";
        }
    },
    a([d(cc.Node)], e.prototype, "node_content", void 0),
    a([d(cc.Prefab)], e.prototype, "pfb_assembly", void 0),
    a([d(cc.Label)], e.prototype, "label_state", void 0),
    a([d(sp.Skeleton)], e.prototype, "sp_cross", void 0),
    a([c], e)
} (cc.Component);
o.default = h